package com.yufei.pfw;

import java.util.Collection;
import java.util.List;
import java.util.Map;

import org.springframework.data.mongodb.MongoDbFactory;
import org.springframework.data.mongodb.core.MongoOperations;

import com.yufei.entity.Entity;

public interface DataRepositoryI {

	/**
	 * @param obj
	 * save entity that has annotion into the collection 
	 */
	public abstract void save(Object obj);

	//批量插入新数据，确保数据没有被保存过
	public abstract void insert(Collection objs);

	//save the entity into a customer collectionName
	public abstract void save(Object obj, String collectionName);

	//query a entity form the collection whose collectionname is the entity's class name
	public abstract <T> T queryEntity(String queryParameter, Object queryValue,
			Class<T> cla);

	public abstract <T> List<T> queryListEntity(String queryParameter,
			Object queryValue, Class<T> cla);

	/**
	 * @param sign:唯一的描述实体，比ID更能生动的描述该实体
	 * @param entity：查询实体
	 * @return
	 */
	public abstract <T> List<T> queryBySign(String sign, Class<T> entity);

	public abstract void updateEntity(Long id, Class entity, String property,
			Object value);

	//查询所有特定集合中的某个字段
	public abstract List queryAllValuesOfField(String fieldName, Class entity,
			Map queryMap);

	public abstract MongoOperations getMongoOperations();

	public abstract void setMongoOperations(MongoOperations mongoOperations);

	//save file
	//public void 
	public abstract MongoDbFactory getMongoDbFactory();

	public abstract void setMongoDbFactory(MongoDbFactory mongoDbFactory);

	/**删除entity实体
	 * @param entity
	 */
	public abstract void removeEntity(Entity entity);
	/**
	 * @param entities
	 * 批量插入数据
	 */
	public abstract void batchInsert(List<? extends Entity> entities);

}